import numpy as np
from io import BytesIO
A = np.array([
    1, 2, 3, 4, 4,
    2, 3, 4, 5, 3,
    4, 5, 6, 7, 2,
    5, 6, 7, 8, 9,
    6, 7, 8, 9, 0 ]).reshape(5,5)


# numpy 转bytes
nda_bytes = BytesIO()
np.save(nda_bytes, A, allow_pickle=False)

# bytes转numpy
nda_bytes = BytesIO(nda_bytes.getvalue())
B = np.load(nda_bytes, allow_pickle=False)
print(np.array_equal(A, B))
